<!DOCTYPE html>
<html lang="cn">
	<head>
		<title>Monitor</title>
		<meta charset="utf-8" />
		<link rel="shortcut icon" href="/favicon.ico" />
		<link href="/assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
		<link href="/assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
        <link href="/assets/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css"/>
        <link href="/assets/plugins/custom/fullcalendar/fullcalendar.bundle.css" rel="stylesheet" type="text/css" />
	</head>

	<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true" data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">
		<div id="vue_body" class="d-flex flex-column flex-root app-root">
			<div class="app-page flex-column flex-column-fluid" id="kt_app_page">

				<home_header></home_header>
				
				<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
					
                    <home_sidebar></home_sidebar>

					<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
						<div class="d-flex flex-column flex-column-fluid">
							<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
								<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
									<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
										<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">个人看板</h1>
										<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
											<li class="breadcrumb-item text-muted">
												<a href="/index.html" class="text-muted text-hover-primary">主页</a>
											</li>
											<li class="breadcrumb-item">
												<span class="bullet bg-gray-400 w-5px h-2px"></span>
											</li>
											<li class="breadcrumb-item text-muted">个人看板</li>
										</ul>
									</div>
								</div>
							</div>

							<div id="kt_app_content" class="app-content flex-column-fluid">
								<div id="kt_app_content_container" class="app-container container-xxl">
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->

									<div class="row g-5 g-xl-10">
										<div class="col-xl-3">
											<a href="#" class="card bg-body hoverable card-xl-stretch mb-xl-8">
												<div class="card-body">
													<span class="svg-icon svg-icon-primary svg-icon-3x ms-n1"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">	<rect x="8" y="9" width="3" height="10" rx="1.5" fill="currentColor" />	<rect opacity="0.5" x="13" y="5" width="3" height="14" rx="1.5" fill="currentColor" />	<rect x="18" y="11" width="3" height="8" rx="1.5" fill="currentColor" />	<rect x="3" y="13" width="3" height="6" rx="1.5" fill="currentColor" /></svg></span>
													<div class="text-gray-900 fw-bold fs-2 mb-2 mt-5">{{data1}}</div>
													<div class="fw-semibold text-gray-400">巡检任务</div>
												</div>
											</a>
										</div>
										<div class="col-xl-3">
											<a href="#" class="card bg-dark hoverable card-xl-stretch mb-xl-8">
												<div class="card-body">
													<span class="svg-icon svg-icon-gray-100 svg-icon-3x ms-n1"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">	<path opacity="0.3" d="M10.9607 12.9128H18.8607C19.4607 12.9128 19.9607 13.4128 19.8607 14.0128C19.2607 19.0128 14.4607 22.7128 9.26068 21.7128C5.66068 21.0128 2.86071 18.2128 2.16071 14.6128C1.16071 9.31284 4.96069 4.61281 9.86069 4.01281C10.4607 3.91281 10.9607 4.41281 10.9607 5.01281V12.9128Z" fill="currentColor" />	<path d="M12.9607 10.9128V3.01281C12.9607 2.41281 13.4607 1.91281 14.0607 2.01281C16.0607 2.21281 17.8607 3.11284 19.2607 4.61284C20.6607 6.01284 21.5607 7.91285 21.8607 9.81285C21.9607 10.4129 21.4607 10.9128 20.8607 10.9128H12.9607Z" fill="currentColor" /></svg></span>
													<div class="text-gray-100 fw-bold fs-2 mb-2 mt-5">{{data2}}</div>
													<div class="fw-semibold text-gray-100">已完成任务</div>
												</div>
											</a>
										</div>
										<div class="col-xl-3">
											<a href="#" class="card bg-warning hoverable card-xl-stretch mb-xl-8">
												<div class="card-body">
													<span class="svg-icon svg-icon-white svg-icon-3x ms-n1"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">	<path opacity="0.3" d="M10.9607 12.9128H18.8607C19.4607 12.9128 19.9607 13.4128 19.8607 14.0128C19.2607 19.0128 14.4607 22.7128 9.26068 21.7128C5.66068 21.0128 2.86071 18.2128 2.16071 14.6128C1.16071 9.31284 4.96069 4.61281 9.86069 4.01281C10.4607 3.91281 10.9607 4.41281 10.9607 5.01281V12.9128Z" fill="currentColor" />	<path d="M12.9607 10.9128V3.01281C12.9607 2.41281 13.4607 1.91281 14.0607 2.01281C16.0607 2.21281 17.8607 3.11284 19.2607 4.61284C20.6607 6.01284 21.5607 7.91285 21.8607 9.81285C21.9607 10.4129 21.4607 10.9128 20.8607 10.9128H12.9607Z" fill="currentColor" /></svg></span>
													<div class="text-white fw-bold fs-2 mb-2 mt-5">{{data3}}</div>
													<div class="fw-semibold text-white">报警数</div>
												</div>
											</a>
										</div>
										<div class="col-xl-3">
											<a href="#" class="card bg-info hoverable card-xl-stretch mb-5 mb-xl-8">
												<div class="card-body">
													<span class="svg-icon svg-icon-white svg-icon-3x ms-n1"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">	<path opacity="0.3" d="M10.9607 12.9128H18.8607C19.4607 12.9128 19.9607 13.4128 19.8607 14.0128C19.2607 19.0128 14.4607 22.7128 9.26068 21.7128C5.66068 21.0128 2.86071 18.2128 2.16071 14.6128C1.16071 9.31284 4.96069 4.61281 9.86069 4.01281C10.4607 3.91281 10.9607 4.41281 10.9607 5.01281V12.9128Z" fill="currentColor" />	<path d="M12.9607 10.9128V3.01281C12.9607 2.41281 13.4607 1.91281 14.0607 2.01281C16.0607 2.21281 17.8607 3.11284 19.2607 4.61284C20.6607 6.01284 21.5607 7.91285 21.8607 9.81285C21.9607 10.4129 21.4607 10.9128 20.8607 10.9128H12.9607Z" fill="currentColor" /></svg></span>
													<div class="text-white fw-bold fs-2 mb-2 mt-5">{{data4}}</div>
													<div class="fw-semibold text-white">已处理数</div>
												</div>
											</a>
										</div>
									</div>


                                    <div class="card mb-5 mb-xxl-8" id="kt_modal_new_target" v-if="role == '管理员'">
										<form id="kt_modal_new_target_form" class="form d-flex flex-column flex-lg-row">
                                            <div class="d-flex flex-column flex-row-fluid">
                                                    <div class="card-header">
                                                        <div class="card-title">
                                                            <h2>制定巡检任务</h2>
                                                        </div>
                                                    </div>
                                                    <div class="card-body pt-0 mt-5">
                                                        <div class="mb-10 fv-row">
                                                            <label class="required form-label">名称</label>
                                                            <input v-model="inspect.title" type="text" class="form-control mb-2"/>
                                                        </div>
                                                        <div class="mb-10 fv-row">
                                                            <label class="required form-label">简介</label>
                                                            <input v-model="inspect.description" type="text" class="form-control mb-2"/>
                                                        </div>

														<div class="mb-10 fv-row">
															<label class="required form-label">巡检人</label>
															<select v-model="inspect.people" class="form-control mb-2" data-placeholder="请点击选择" data-hide-search="true">
																<option v-for="person in user" :value="person.name">{{person.name}}</option>
															</select>
														</div>

														<div class="mb-10 fv-row">
															<label class="required form-label">日期</label>
															<div class="position-relative d-flex align-items-center" >
																<span class="svg-icon svg-icon-2 position-absolute mx-4"><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">	<path opacity="0.3" d="M21 22H3C2.4 22 2 21.6 2 21V5C2 4.4 2.4 4 3 4H21C21.6 4 22 4.4 22 5V21C22 21.6 21.6 22 21 22Z" fill="currentColor" />	<path d="M6 6C5.4 6 5 5.6 5 5V3C5 2.4 5.4 2 6 2C6.6 2 7 2.4 7 3V5C7 5.6 6.6 6 6 6ZM11 5V3C11 2.4 10.6 2 10 2C9.4 2 9 2.4 9 3V5C9 5.6 9.4 6 10 6C10.6 6 11 5.6 11 5ZM15 5V3C15 2.4 14.6 2 14 2C13.4 2 13 2.4 13 3V5C13 5.6 13.4 6 14 6C14.6 6 15 5.6 15 5ZM19 5V3C19 2.4 18.6 2 18 2C17.4 2 17 2.4 17 3V5C17 5.6 17.4 6 18 6C18.6 6 19 5.6 19 5Z" fill="currentColor" />	<path d="M8.8 13.1C9.2 13.1 9.5 13 9.7 12.8C9.9 12.6 10.1 12.3 10.1 11.9C10.1 11.6 10 11.3 9.8 11.1C9.6 10.9 9.3 10.8 9 10.8C8.8 10.8 8.59999 10.8 8.39999 10.9C8.19999 11 8.1 11.1 8 11.2C7.9 11.3 7.8 11.4 7.7 11.6C7.6 11.8 7.5 11.9 7.5 12.1C7.5 12.2 7.4 12.2 7.3 12.3C7.2 12.4 7.09999 12.4 6.89999 12.4C6.69999 12.4 6.6 12.3 6.5 12.2C6.4 12.1 6.3 11.9 6.3 11.7C6.3 11.5 6.4 11.3 6.5 11.1C6.6 10.9 6.8 10.7 7 10.5C7.2 10.3 7.49999 10.1 7.89999 10C8.29999 9.90003 8.60001 9.80003 9.10001 9.80003C9.50001 9.80003 9.80001 9.90003 10.1 10C10.4 10.1 10.7 10.3 10.9 10.4C11.1 10.5 11.3 10.8 11.4 11.1C11.5 11.4 11.6 11.6 11.6 11.9C11.6 12.3 11.5 12.6 11.3 12.9C11.1 13.2 10.9 13.5 10.6 13.7C10.9 13.9 11.2 14.1 11.4 14.3C11.6 14.5 11.8 14.7 11.9 15C12 15.3 12.1 15.5 12.1 15.8C12.1 16.2 12 16.5 11.9 16.8C11.8 17.1 11.5 17.4 11.3 17.7C11.1 18 10.7 18.2 10.3 18.3C9.9 18.4 9.5 18.5 9 18.5C8.5 18.5 8.1 18.4 7.7 18.2C7.3 18 7 17.8 6.8 17.6C6.6 17.4 6.4 17.1 6.3 16.8C6.2 16.5 6.10001 16.3 6.10001 16.1C6.10001 15.9 6.2 15.7 6.3 15.6C6.4 15.5 6.6 15.4 6.8 15.4C6.9 15.4 7.00001 15.4 7.10001 15.5C7.20001 15.6 7.3 15.6 7.3 15.7C7.5 16.2 7.7 16.6 8 16.9C8.3 17.2 8.6 17.3 9 17.3C9.2 17.3 9.5 17.2 9.7 17.1C9.9 17 10.1 16.8 10.3 16.6C10.5 16.4 10.5 16.1 10.5 15.8C10.5 15.3 10.4 15 10.1 14.7C9.80001 14.4 9.50001 14.3 9.10001 14.3C9.00001 14.3 8.9 14.3 8.7 14.3C8.5 14.3 8.39999 14.3 8.39999 14.3C8.19999 14.3 7.99999 14.2 7.89999 14.1C7.79999 14 7.7 13.8 7.7 13.7C7.7 13.5 7.79999 13.4 7.89999 13.2C7.99999 13 8.2 13 8.5 13H8.8V13.1ZM15.3 17.5V12.2C14.3 13 13.6 13.3 13.3 13.3C13.1 13.3 13 13.2 12.9 13.1C12.8 13 12.7 12.8 12.7 12.6C12.7 12.4 12.8 12.3 12.9 12.2C13 12.1 13.2 12 13.6 11.8C14.1 11.6 14.5 11.3 14.7 11.1C14.9 10.9 15.2 10.6 15.5 10.3C15.8 10 15.9 9.80003 15.9 9.70003C15.9 9.60003 16.1 9.60004 16.3 9.60004C16.5 9.60004 16.7 9.70003 16.8 9.80003C16.9 9.90003 17 10.2 17 10.5V17.2C17 18 16.7 18.4 16.2 18.4C16 18.4 15.8 18.3 15.6 18.2C15.4 18.1 15.3 17.8 15.3 17.5Z" fill="currentColor" /></svg></span>
																<input v-model="inspect.start" class="form-control ps-12" placeholder="请点击选择" name="due_date"  id="kt_td_picker_date_only"/>
															</div>
														</div>

                                                        <div class="mb-1 fv-row" @click="controllerFile()">
                                                            <label class="form-label">文件</label>
                                                            <div class="fv-row mb-2">
																<div class="dropzone" id="kt_ecommerce_add_product_media">
																	<div class="dz-message needsclick">
																		<i class="bi bi-file-earmark-arrow-up text-primary fs-3x"></i>
																		<div class="ms-4">
																			<h3 class="fs-5 fw-bold text-gray-900 mb-1">选择文件</h3>
																			<span class="fs-7 fw-semibold text-gray-400">{{fileName}}</span>
																		</div>
                                                                        <input type="file" style="opacity:0;" ref="fileInput" @change="editStyle()"/>
																	</div>
																</div>
															</div>
                                                        </div>
                                                    </div>
													<div class="card-footer d-flex justify-content-end py-6 px-9">
														<button type="reset" class="btn btn-light btn-active-light-primary me-2">取消</button>
														<button @click="addInspect()" type="button" class="btn btn-primary">提交</button>
													</div>
                                            </div>
                                        </form>
									</div>


									<div class="card card-flush mb-5" v-if="role == '管理员'">
										<div class="card-header card-header-stretch">
											<div class="card-title d-flex align-items-center">
												<span class="svg-icon svg-icon-1 svg-icon-primary me-3 lh-0">
													<i class="bi bi-calendar-week" style="font-size: 1.5rem;"></i>
												</span>
												<h3 class="fw-bold m-0 text-gray-800">巡检任务</h3>
											</div>
										</div>

										<div class="card-body pt-0">
											<table class="table align-middle table-row-dashed fs-6 gy-5" id="kt_ecommerce_report_views_table">
												<thead>
													<tr class="text-start text-gray-400 fw-bold fs-7 text-uppercase gs-0">
														<th style="text-align: center;">名称</th>
														<th style="text-align: center;">简介</th>
														<th style="text-align: center;">巡检人</th>
														<th style="text-align: center;">日期</th>
														<th style="text-align: center;"></th>
													</tr>
												</thead>
												<tbody class="fw-semibold text-gray-600">
													<tr v-for="inspect in inspects">
														<td style="text-align: center;">
															<span>{{inspect.title}}</span>
														</td>
														
														<td style="text-align: center;">
															<span>{{inspect.description}}</span>
														</td>
                                                        <td style="text-align: center;">
															<span>{{inspect.people}}</span>
														</td>
														<td style="text-align: center;">
															<span>{{inspect.start}}</span>
														</td>
														<td style="text-align: center;">
															<a :href="'http://182.92.232.96:9000/inspect/' + inspect.title + '.docx'" class="btn btn-primary btn-sm" >下载</a>
															<button @click="deleteInspect(inspect.title)" class="btn btn-primary btn-sm" >删除</button>
														</td>
													</tr>
												</tbody>
											</table>
										</div>
									</div>




									<div class="card card-flush mb-7">

										<div class="card-header card-header-stretch">
											<div class="card-title d-flex align-items-center">
												<span class="svg-icon svg-icon-1 svg-icon-primary me-3 lh-0">
													<i class="bi bi-calendar-week" style="font-size: 1.5rem;"></i>
												</span>
												<h3 class="fw-bold m-0 text-gray-800">已提交巡检报告</h3>
											</div>
										</div>

										<div class="card-body pt-0">
											<table class="table align-middle table-row-dashed fs-6 gy-5" id="kt_ecommerce_report_views_table">
												<thead>
													<tr class="text-start text-gray-400 fw-bold fs-7 text-uppercase gs-0">
														<th style="text-align: center;">名称</th>
														<th style="text-align: center;">规定时间</th>
														<th style="text-align: center;">提交时间</th>
														<th style="text-align: center;">问题情况</th>
														<th style="text-align: center;"></th>
													</tr>
												</thead>
												<tbody class="fw-semibold text-gray-600">
													<tr v-for="inspect in inspects" v-if="inspect.end_date.length != 0">
														<td style="text-align: center;">
															<span>{{inspect.title}}</span>
														</td>
														<td style="text-align: center;">
															<span>{{inspect.start}}</span>
														</td>
														<td  style="text-align: center;">
															<span>{{inspect.end_date|formatDate('yyyy-M-d')}}</span>
														</td>
                                                        <td  style="text-align: center;">
															<span>{{inspect.problem}}</span>
														</td>
														<td style="text-align: center;">
															<a :href="'http://182.92.232.96:9000/secondinspect/' + inspect.title + '.docx'" class="btn btn-primary btn-sm" >下载</a>
															<button @click="deleteSecondInspect(inspect.title)" class="btn btn-primary btn-sm" v-if="inspect.people == name">删除</button>
														</td>
													</tr>
												</tbody>
											</table>
										</div>

									</div>



									<div class="card card-flush mb-5">
										<div class="card-header card-header-stretch">
											<div class="card-title d-flex align-items-center">
												<span class="svg-icon svg-icon-1 svg-icon-primary me-3 lh-0">
													<i class="bi bi-calendar-week" style="font-size: 1.5rem;"></i>
												</span>
												<h3 class="fw-bold m-0 text-gray-800">已提交工单</h3>
											</div>
										</div>

										<div class="card-body pt-0">
											<table class="table align-middle table-row-dashed fs-6 gy-5" id="kt_ecommerce_report_views_table">
												<thead>
													<tr class="text-start text-gray-400 fw-bold fs-7 text-uppercase gs-0">
														<th style="text-align: center;">名称</th>
														<th style="text-align: center;">发生时间</th>
														<th style="text-align: center;">提交时间</th>
														<th style="text-align: center;">问题情况</th>
														<th style="text-align: center;"></th>
													</tr>
												</thead>
												<tbody class="fw-semibold text-gray-600">
													<tr v-for="alert in alerts" v-if="alert.submit_date.length != 0 && alert.responsible_name == name">
														<td style="text-align: center;">
															<span>{{alert.name}}</span>
														</td>
														<td style="text-align: center;">
															<span>{{alert.start_data|formatDate('yyyy-M-d')}}</span>
														</td>
														
														<td style="text-align: center;">
															<span>{{alert.submit_date|formatDate('yyyy-M-d')}}</span>
														</td>
                                                        <td style="text-align: center;">
															<span>{{alert.submit_note}}</span>
														</td>
														<td style="text-align: center;">
															<a :href="'http://182.92.232.96:9000/alert/' + alert.id + '.docx'" class="btn btn-primary btn-sm" >下载</a>
															<button @click="deleteAlert(alert.id)" class="btn btn-primary btn-sm">删除</button>
														</td>
													</tr>
												</tbody>
											</table>
										</div>
									</div>

									



                                
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
                                    <!-- ------------------------------------------------------------------------------------------- -->
								</div>
							</div>
						</div>

						<home_footer></home_footer>

					</div>
				</div>
			</div>
		</div>
	</body>
    <script src="/assets/plugins/global/plugins.bundle.js"></script>
	<script src="/assets/js/scripts.bundle.js"></script>
	<script src="/assets/plugins/custom/datatables/datatables.bundle.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
	<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>

	<script src="/ownJS/person.js"></script>


	<script>
		
    
        
        
		new Vue({
        	el: "#vue_body",
			components: {
                "home_sidebar": httpVueLoader("/plug_in/home_sidebar.vue"),
				"home_footer": httpVueLoader("/plug_in/home_footer.vue"),
				"home_header": httpVueLoader("/plug_in/home_header.vue"),                
            },
        	data: {
                fileName: "文件名",
				name: localStorage.getItem("nameForUser"),
				// role: localStorage.getItem("role"),
				role: '管理员',
				inspects: [{
					title: "",
					description: "",
					people: "",
					start: "",
					end_date: "",
					problem: "",
				}],

				inspect: {
					title: "",
					description: "",
					people: "",
					start: "",
					author: localStorage.getItem("nameForUser"),
				},

				user: [{
					name: ""
				}],

				alerts: [{
					id: "",
					name: "",
					responsible_name: "",
					start_data: "",
					monitor_name: "",
					submit_date: "",
					submit_note: ""
				}],
				data1: "",
				data2: "",
				data3: "",
				data4: "",
            },
			methods: {
				// 代点击为file的input
				controllerFile() {
                    this.$refs.fileInput.click();
                },

				// 变一下显示文件名
                editStyle() {
                    this.fileName = this.$refs.fileInput.files[0].name;
                },

				// 获取用户姓名
				getUser() {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/inspect/getUser",
            		})
					.then(resp => {
						console.log(resp.data.data);
						this.user = resp.data.data;
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 上传文件
				uploadFile(file) {
  					const xhr = new XMLHttpRequest();
  					xhr.open('PUT', 'http://182.92.232.96:9000/inspect/' + this.inspect.title + '.docx', true);
  					xhr.setRequestHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
  					xhr.setRequestHeader('x-amz-acl', 'public-read'); // 可选，如果需要对上传的文件设置访问权限
  					xhr.onload = function() {
  					  if (xhr.status === 200) {
  					    console.log('文件上传成功');
  					  } else {
  					    console.error('文件上传失败', xhr.responseText);
  					  }
  					};
  					xhr.send(file);
				},

				// 添加巡检任务
				addInspect() {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/inspect/addInspect",
						data: JSON.stringify(this.inspect),
            		})
					.then(resp => {
						console.log(resp.data.data);
						this.uploadFile(this.$refs.fileInput.files[0])
						setTimeout(function (){
							// 刷新页面
							location.reload();
						}, 4000);
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 获取所有巡检任务
				getInspect() {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/inspect/getInspect",
            		})
					.then(resp => {
						console.log(resp.data.data);
						this.inspects = resp.data.data;
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 删除巡检任务
				deleteInspect(title) {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/inspect/deleteInspect",
						data: JSON.stringify({"title": title})
            		})
					.then(resp => {
						location.reload();
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 删除已提交的巡检任务（吧end_date删除）
				deleteSecondInspect(title) {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/inspect/deleteSecondInspect",
						data: JSON.stringify({"title": title})
            		})
					.then(resp => {
						location.reload();
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 获得自己负责的报警
				getAlert() {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/alert/getAlert",
            		})
					.then(resp => {
						console.log(resp.data.data);
						this.alerts = resp.data.data;
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},

				// 删除自己负责的报警
				deleteAlert(id) {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/alert/deleteAlert",
						data: JSON.stringify({"id": id})
            		})
					.then(resp => {
						location.reload();
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				},
				
				getPerson() {
					axios({
                		method: "post",
                		headers: {
							"Content-Type": "application/json;charset=UTF-8"
                		},
						withCredentials: true,
                		url: "http://127.0.0.1:8088/common/forPerson",
						data: JSON.stringify({"name": this.name})
            		})
					.then(resp => {
						this.data1 = resp.data.data[0];
                		this.data2 = resp.data.data[1];
                		this.data3 = resp.data.data[2];
                		this.data4 = resp.data.data[3];
                	})
                	.catch(err => {
                    	console.log(err);
                	})
				}

				


            },

            mounted() {
				this.getUser();
				this.getInspect();
				this.getAlert();
				this.getPerson();
            },
			filters:{
				formatDate: function(value,args) {
					var dt = new Date(value);
					if(args == 'yyyy-M-d') {// yyyy-M-d
						let year = dt.getFullYear();
						let month = dt.getMonth() + 1;
						let date = dt.getDate();
						return `${year}-${month}-${date}`;
					} else if(args == 'yyyy-M-d H:m:s'){// yyyy-M-d H:m:s
						let year = dt.getFullYear();
						let month = dt.getMonth() + 1;
						let date = dt.getDate();
						let hour = dt.getHours();
						let minute = dt.getMinutes();
						let second = dt.getSeconds();
						return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
					} else if(args == 'yyyy-MM-dd') {// yyyy-MM-dd
						let year = dt.getFullYear();
						let month = (dt.getMonth() + 1).toString().padStart(2,'0');
						let date = dt.getDate().toString().padStart(2,'0');
						return `${year}-${month}-${date}`;
					} else {// yyyy-MM-dd HH:mm:ss
						let year = dt.getFullYear();
						let month = (dt.getMonth() + 1).toString().padStart(2,'0');
						let date = dt.getDate().toString().padStart(2,'0');
						let hour = dt.getHours().toString().padStart(2,'0');
						let minute = dt.getMinutes().toString().padStart(2,'0');
						let second = dt.getSeconds().toString().padStart(2,'0');
						return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
					}
        		}
			},
			
			

   		})

       
	</script>
</html>




